<template>
    <div>
      <table>
        <tr>
          <td>图片</td>
          <td>标题</td>
          <td>价格</td>
          <td>操作</td>
        </tr>
        <tr v-for="item in goodlist">
          <td><img :src="'http://127.0.0.1:8000/imgs/'+item.img" alt="" width="10" height="10"></td>
          <td>{{ item.name }}</td>
          <td v-if="name==null">{{ item.price }}</td>
          <td v-else>{{ item.vip_price }}</td>
          <td v-if="name==null"><router-link :to="{path: '/login'}">立即预定</router-link></td>
          <td v-else><router-link :to="{path: '/ding', query: {gid:item.id }}">立即预定</router-link></td>
        </tr>
      </table>
    </div>
</template>

<script>
    import axios from "axios";

    export default {
        name: "good",
        data(){
          return{
            goodlist:[],
            name:'',

          }
        },
        mounted() {
          var names = localStorage.getItem('name');
          axios({
              method: 'post',
              url: 'http://127.0.0.1:8000/good/',
              data:{'name':names}

            }).then(res => {
              console.log(res);
              this.goodlist = res.data.good;
              // this.users = res.data.users;
              this.name = names;
              localStorage.setItem('uid',res.data.users.id)

              // this.$router.push('/good')
            })


        },
        // methods:{
        //   submit(id){
        //     axios({
        //       method: 'post',
        //       url: 'http://127.0.0.1:8000/ding/',
        //       data:{'name':name,'gid':id}
        //
        //     }).then(res => {
        //       console.log(res);
        //
        //
        //       this.$router.push('/ding')
        //     })
        //
        //
        //   }



        // }
    }
</script>

<style scoped>

</style>
